package com.fire.market.controller;

import com.fire.component.dto.Response;
import com.fire.component.extension.Assert;
import com.fire.market.promo.api.service.PromoCmdFrontService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * PromoCmdController
 *
 * @author zwd
 * @date 2021/7/21
 */
@RestController
@RequestMapping("/promo/cmd")
@Api(tags = "促销Cmd操作")
public class PromoCmdController {
    @Reference(timeout = 30000)
    PromoCmdFrontService promoCmdFrontService;

    @PostMapping("/publishPromoItem/{itemId}")
    @ApiOperation(value = "发布商品信息", notes = "发布商品信息")
    @ApiImplicitParam(name = "itemId", value = "商品id", required = true, dataType = "Integer")
    public Response publishPromo(@PathVariable("itemId") Integer itemId){
        Assert.notNull(itemId, "itemId is null");
        promoCmdFrontService.publishPromo(itemId);
        return Response.buildSuccess();
    }
}
